function request(method: 'GET' | 'POST') {
	/**
	 * url: string;
	 * data?: string | any;
	 * header?: RequestHeader;
	 * method?: string;
	 */
	return (url: string, data?: any) => {
		// const header = {
		// 	cookie: my.setStorageSync('sessionid')
		// };
		return new Promise<my.DataResponse>((resolve, reject) => {
			my.httpRequest({
				data,
				dataType: 'json',
				// header,
				method,
				url,
				success(res: any) {
					if (res.status > 0 && res.status < 400) {
						resolve(res);
					} else {
						reject(res);
					}
				},
				fail(res: any) {
					reject(res);
				}
			});
		});
	};
}

export function get(url: string, data?: any) {
	return request('GET')(url, data);
}

export function post(url: string, data: any) {
	return request('POST')(url, data);
}
